const http = require("http");

http
  .createServer((req, res) => {
    console.log(req.method);
    res.setHeader("Content-Type", "text/plain");
    if (req.method === "POST") {
      res.end("post");
    } else if (req.method === "GET") {
      res.end("get");
    } else {
      res.statusCode = 405; // Method Not Allowed
      res.end("Method not allowed");
    }
  })
  .listen(3456, () => {
    console.log("启动成功");
  });
